package service

import (
	"go-web/dao"
	"go-web/model"
)

type UserService struct {
	userDao *dao.UserDao
}

func NewUserService() *UserService {
	return &UserService{userDao: dao.NewUserDao()}
}

func (s *UserService) CreateUser(user *model.User) error {
	return s.userDao.Create(user)
}

func (s *UserService) GetUserByID(id uint) (*model.User, error) {
	return s.userDao.GetByID(id)
}

func (s *UserService) GetUserByUsername(username string) (*model.User, error) {
	return s.userDao.GetByUsername(username)
}

func (s *UserService) UpdateUser(user *model.User) error {
	return s.userDao.Update(user)
}

func (s *UserService) DeleteUser(id uint) error {
	return s.userDao.Delete(id)
}

func (s *UserService) ListUsers(page, pageSize int) ([]model.User, int64, error) {
	return s.userDao.List(page, pageSize)
}
